package com.zxp00.JavaBasics;

import java.util.Scanner;

public class Z04_If_Switch {
    /*if条件语句*/
    public static void if_demo(){
        Scanner sc = new Scanner(System.in);
        System.out.println("输入分数");
        Double score=sc.nextDouble();          // 输入double类型
        if (score<60 && score>=0){
            System.out.println("不及格");
        }else if (score>=60 && score<80){
            System.out.println("及格");
        }else if (score>=80 && score<=100){
            System.out.println("优秀");
        }else {
            System.out.println("请输入正常数字");
        }
    }

    /*switch条件语句*/
    public static void switch_demo(){
        Scanner sc = new Scanner(System.in);
        String weekday =sc.nextLine();
        switch (weekday){
            case "周一":
                System.out.println("周一穿这个");
                break;
            case "周二":
                System.out.println("周二穿这个");
                break;
            case "周三":
                System.out.println("周三穿这个");
                break;
            case "周四":
                System.out.println("周四穿这个");
                break;
            case "周五":
                System.out.println("周五穿这个");
                break;
            case "周六":
                System.out.println("周六穿这个");
                break;
            case "周日":
                System.out.println("周日穿这个");
                break;
            default:                       //上面的值都不满足时执行此段代码
                System.out.println("数据有误");
        }
    }

    /*switch不使用break时的穿透现象*/
    public static void switch_NoBreak(){
        Scanner sc =new Scanner(System.in);
        int month = sc.nextInt();
        switch (month){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println(month+"月是31天");
                break;
            case 2:
                System.out.println("2月，闰年是28天，平年是27天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println(month+"月是30天");
        }
    }

    public static void main(String[] args) {
//        if_demo();
//        switch_demo();
        switch_NoBreak();
    }
}
